﻿#ifndef HTTP_H
#define HTTP_H

#include "communicationprotocol.h"
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QObject>

struct HttppParaTypeDef {
    QString url_str;
};

class UPWARDPRO_EXPORT Http : public CommunicationProtocol {
    Q_OBJECT
public:
    Http();

    int httpParaSet(const QString& url_str);
    virtual int protocolParaInit(void* para_struct) override;
    virtual int protocolOpen() override;
    virtual int protocolWrite(const QByteArray& data_buf) override;
    virtual int protocolClose() override;
    virtual void setProtocolReadCallbackFunc(ReceiveDataCallback callBackFunc) override;
    ~Http();

private:
    QNetworkAccessManager* m_manager;
    QNetworkRequest* m_request;
    QUrl m_url;

    ReceiveDataCallback receiveDataCallback = nullptr;
};

#endif // HTTP_H
